package com.example.demo.app;

/**
 * @author hanbaoyu
 */

public class Response {

    private Integer code;

    private Object data;

    private String message;

    public Response(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }


    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }


    public static Response success(Object data) {
        return new Response(ResponseEnum.OK.getCode(), ResponseEnum.OK.getMessage(), data);
    }

    public static Response error(Integer code, String message) {
        return new Response(code, message, null);
    }

    public static Response error(String message) {
        return error(ResponseEnum.ERROR.getCode(), message);
    }

}

